package com.mywebsite.core.client.dashboard.place;

import com.google.gwt.place.shared.PlaceTokenizer;
import com.google.gwt.place.shared.Prefix;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.mywebsite.core.client.dashboard.activity.DashboardActivity;
import com.mywebsite.core.client.mvp.ActivityPlace;

public class DashboardPlace extends ActivityPlace<DashboardActivity> {

	public static final String TOKEN_NAME="dashboard";
	
	@Inject
	public DashboardPlace(DashboardActivity activity) {
		super(activity);
	}
	@Override
	public DashboardActivity getActivity() {
		activity.init(this);
		return activity;
	}

	@Prefix(TOKEN_NAME)
	public static class Tokenizer implements PlaceTokenizer<DashboardPlace> {
		private final Provider<DashboardPlace> dashboardPlaceProvider;
		@Inject
		public Tokenizer(Provider<DashboardPlace> dashboardPlaceProvider) {
			this.dashboardPlaceProvider = dashboardPlaceProvider;
		}

		@Override
		public DashboardPlace getPlace(String token) {
			DashboardPlace place=dashboardPlaceProvider.get();
			place.setPlaceName(token);
			return place;
		}

		@Override
		public String getToken(DashboardPlace place) {
			return place.getPlaceName();
		}
	}

}
